import { checkPassword, checkUsername } from "./utils/check.js";

import './index.css'
import './index.less'
import logo from "./assets/logo.png";
import axios from "axios";

document.querySelector('.logo-img').src = logo

const sub = document.querySelector('.login-btn')
sub.addEventListener('click', function () {
    const username = document.querySelector('.username').value
    const password = document.querySelector('.password').value
    console.log(username, password)
    if (!(checkUsername(username))) {
        alert('用户名长度需要大于6位')
        return
    }
    if (!(checkPassword(password))) {
        alert('密码长度需要大于6位')
        return
    }

    axios.post('https://hmajax.itheima.net/api/register', {
        username: username,
        password: password
    }).then(res => {
        alert('注册成功,ID为'+res.data.data.id)
    }).catch(err => {
        alert(err.response.data.message)
    })
})



